import React, { useEffect, useState, useRef } from 'react';
import TableDataBlock from '@/components/TableDataBlock';
import PopImgShow from '@/components/PopImgShow';
import { connect } from 'umi';
import { Space } from 'antd'

import { order_status, goodsType_status, workType_status, after_sale_type } from '@/common/contact';
const PointDetail = (props) => {
  const { dispatch, visible = {}, onClose, loading, list } = props;
  const { show = false, detail = {} } = visible;
  const { id } = props
  const getColumns = [
    {
      title: '订单时间',
      dataIndex: 'createTime',
    },
    {
      title: '订单信息',
      dataIndex: 'orderDesc',
      render: (e) => {
        const goods = e ? JSON.parse(e) : {}
        const { goodsCover, goodsName } = goods
        return <Space>
          <PopImgShow url={goodsCover}></PopImgShow>
          <div>{goodsName}</div>
        </Space>
      }
    },
    {
      title: '订单编号',
      dataIndex: 'orderSn',
    },
    {
      title: '订单类型',
      dataIndex: 'orderType',
      render: (e) => {
        return goodsType_status[e]
      },
    },
    {
      title: '售后编号',
      align: 'center',
      dataIndex: 'afterSaleNo',
    },
    {
      title: '售后类型',
      dataIndex: 'afterSaleType',
      render: (e) => {
        return after_sale_type[e]
      },
    },
    {
      title: '创建人',
      dataIndex: 'addAdminName',
    },
    {
      title: '服务类型',
      dataIndex: 'workType',
      render: (e) => {
        return workType_status[e]
      }
    },
       {
      title: '阶段',
      dataIndex: 'stageInfo',
      render: (e = {}) => {
        const { stageName } = e
        return stageName || '--'
      }
    },

    {
      title: '应收',
      dataIndex: 'payFee',
    }, {
      title: '实收',
      dataIndex: 'realPayFee',
    },
    {
      title: '欠费',
      dataIndex: 'remainMoney',
    },
    {
      title: '状态',
      dataIndex: 'status',
      render: (e) => {
        return order_status[e]
      },
    },
    {
      title: '商品数量',
      dataIndex: 'goodsAmount',
    },
    {
      title: '支付时间',
      dataIndex: 'payTime',
    },
    {
      title: '复核人',
      dataIndex: 'checkAdminName',
    },
    {
      title: '复核时间',
      dataIndex: 'checkTime',
    },
  ];
  const childRef = useRef();
  return (
    <TableDataBlock
      params={{ organizationUserId: id }}
      cRef={childRef}
      loading={loading}
      columns={getColumns}
      rowKey={(record) => `${record.orderSn}`}
      dispatchType="order/fetchListUserOrder"
      {...list}
    ></TableDataBlock>
  );
};
export default connect(({ order, loading }) => ({
  list: order.orderUseList,
  loading: loading.effects['order/fetchListUserOrder'],
}))(PointDetail);;
